package 剑指offer;

public class M9 {
    public int numSubarrayProductLessThanK(int[] nums, int k) {
        long middle=1;
        int count=0;
        int le=0;
        int ri=0;
        while (ri<nums.length-1) {
            ri++;
            middle*=nums[ri-1];
            while (le<=ri&&middle>=k) {
                middle/=nums[le++];
            }
            count+=ri-le>=0?ri-le+1:0;
           
        }
        return count;
    }
}
